y=eval(input())
m=eval(input())
d=eval(input())
if y>9999 or m>12 or d>31:
	print('日期格式错误')
#四年一闰,百年不闰,四百年再闰
else:
    if (y%4==0 and y%100!=0)or (y%100==0 and y%400==0) :
	    mon=[31,29,31,30,31,30,31,31,30,31,30,31]
    else:
	    mon=[31,28,31,30,31,30,31,31,30,31,30,31]
    day=sum(mon[0:m-1])+d
    print('{}年{}月{}日是{}年第{}天'.format(y,m,d,y,day))
